package org.lw.provider.mapper;

import org.apache.ibatis.annotations.*;
import org.lw.provider.Entity.User;


import java.util.List;

@Mapper
public interface UserMapper {

    // 插入用户
    @Insert("INSERT INTO User (username, age) VALUES (#{username}, #{age})")
    void insertUser(User user);

    // 根据 ID 查询用户
    @Select("SELECT * FROM User WHERE id = #{id}")
    User getUserById(int id);

    // 查询所有用户
    @Select("SELECT * FROM User")
    List<User> getAllUsers();

    // 更新用户
    @Update("UPDATE User SET username = #{username}, age = #{age} WHERE id = #{id}")
    void updateUser(User user);

    // 删除用户
    @Delete("DELETE FROM User WHERE id = #{id}")
    void deleteUser(int id);
}

